Lynda Accessing Databases with Object Oriented PHP
Now that PHP has true object-oriented capabilities, it's best practice to access databases using PDO (PHP Data Objects) and MySQLi. These methods produce database-neutral code that works with over a dozen systems, including MySQL, SQL Server, PostgreSQL, and SQLite. Learn how to use PDO and MySQLi to perform basic select, insert, update, and delete operations; improve security with prepared statements; and use transactions to execute multiple queries simultaneously. Author David Powers also covers advanced topics like instantiating custom objects, and compares PDO to MySQLi so you can decide which method is right for you.
Topics include:- Connecting to a database with PDO or MySQLi
- Fetching a result set
- Executing simple non-SELECT queries
- Sanitizing user input
- Binding input and output values
- Passing an array of values to the execute() method
- Working with advanced PDO fetch methods
- Executing a MySQLi transaction
- Freeing resources that are no longer needed
- Submitting multiple queries
- Creating an instance of a class from a result set
Introduction
13m 33s- Welcome
- 1m 4s
- What you should know before watching this course
- 2m 8s
- Using the exercise files
- 4m 56s
- Setting SQLite permissions
- 1m 11s
- A quick primer on using PHP objects
- 4m 14s
1. Why Use Object-Oriented PHP to Access a Database?
10m 12s- Overview of PHP database APIs
- 4m 5s
- Using prepared statements
- 4m 24s
- Using transactions
- 1m 43s
2. PHP Data Object (PDO) Basics
48m 57s- Creating a database source name
- 2m 3s
- Connecting to a database with PDO
- 7m 27s
- Looping directly over a SELECT query
- 3m 49s
- Fetching a result set
- 8m 3s
- Finding the number of results from a SELECT query
- 7m 14s
- Checking if a SELECT query contains results
- 3m 32s
- Executing simple non-SELECT queries
- 6m 2s
- Getting error messages
- 7m 17s
- Using the quote() method to sanitize user input
- 3m 30s
3. PDO-Prepared Statements and Transactions
39m 51s- Binding input and output values
- 2m 36s
- Using named parameters
- 9m 51s
- Using question marks as anonymous placeholders
- 2m 35s
- Passing an array of values to the execute() method
- 5m 20s
- Binding results to variables
- 7m 53s
- Executing a transaction
- 6m 54s
- Closing the cursor before running another query
- 4m 42s
4. Advanced PDO Fetch Methods
21m 20s- Generating an array from a pair of columns
- 2m 44s
- Setting an existing object's properties with a database result
- 4m 42s
- Creating an instance of a specific class with a database result
- 6m 1s
- Reusing a result set
- 7m 53s
5. MySQL Improved Basics
38m 14s- Connecting to a database with MySQLi
- 5m 57s
- Setting the character set
- 1m 57s
- Submitting a SELECT query and getting the number of results
- 4m 4s
- Fetching the result
- 7m 35s
- Rewinding the result for reuse
- 3m 20s
- Handling non-SELECT queries
- 5m 27s
- Getting error messages
- 5m 47s
- Sanitizing user input with real_escape_string()
- 4m 7s
6. MySQLi Prepared Statements and Transactions
27m 49s- Initializing and preparing a statement
- 4m 17s
- Binding parameters and executing a prepared statement
- 5m 55s
- Binding output variables
- 5m 6s
- Executing a MySQLi transaction
- 7m 5s
- Dealing with "commands out of sync" in prepared statements
- 5m 26s
7. Diving Deeper into MySQLi
24m 7s- Buffered and unbuffered queries
- 4m 19s
- Using real_query()
- 6m 1s
- Freeing resources that are no longer needed
- 2m 31s
- Submitting multiple queries
- 6m 41s
- Creating an instance of a class from a result set
- 4m 35s
Conclusion
3m 31s- PDO and MySQLi compared
- 3m 31s